找传奇、传世资源到传世资源站!

egret黑白方块源码

8.5玩家评分(1人评分)
下载后可评
介绍 评论 失效链接反馈

egret游戏框架做的黑白方块游戏egret黑白方块源码 网页游戏-第1张egret黑白方块源码 网页游戏-第2张class GameView extends egret.Sprite{ public constructor() { super(); this.init(); } private _boxGroups:Array<BoxGroup>; //private scoreText:egret.TextField; private scoreText:egret.BitmapText; private init():void { this._boxGroups = []; var len:number = GameData.row 1; for(var i:number=0;i<len;i ) { var boxg:BoxGroup = new BoxGroup(); this._boxGroups.push(boxg); this.addChild(boxg); boxg.addEventListener(GameEvent.GAME_OVER, this.gameOver, this); boxg.addEventListener(GameEvent.GAME_HIT, this.gamehit, this); } /* this.scoreText = new egret.TextField(); this.scoreText.textColor = 0xff0000; this.scoreText.bold = true; this.scoreText.size = 100; */ this.scoreText = new egret.BitmapText(); this.scoreText.font = RES.getRes("number_fnt"); this.scoreText.x = 180; this.scoreText.y = 50; this.scoreText.text = String(0); this.addChild(this.scoreText); } public startgame():void { this.scoreText.text = String(0); var len:number = GameData.row 1; for(var i:number=0;i<len;i ) { this._boxGroups[i].create(); this._boxGroups[i].y = 0-GameData.getBoxHeight()*(1 i);//GameData.getStageHeight()-GameData.getBoxHeight()*(1 i); } } //移动 public move() { var len:number = GameData.row 1; for(var i:number=0;i<len;i ) { this._boxGroups[i].y = GameData.speed; } for(i=0;i<len;i ) { if(this._boxGroups[i].y>=GameData.getStageHeight())//移动到舞台外侧了 { if(!this._boxGroups[i].isHit) { this.gameOver(); return; } if(i==0) { this._boxGroups[i].y = this._boxGroups[4].y - GameData.getBoxHeight(); } else { this._boxGroups[i].y = this._boxGroups[i-1].y - GameData.getBoxHeight(); } this._boxGroups[i].create(); } } } private gameOver(evt:GameEvent=null):void { var event:GameEvent = new GameEvent(GameEvent.GAME_OVER); this.dispatchEvent(event); } private gamehit(evt:GameEvent):void { GameData.setScore(GameData.getScore() 1); this.scoreText.text = String(GameData.getScore()); }}

评论

发表评论必须先登陆, 您可以 登陆 或者 注册新账号 !


在线咨询: 问题反馈
客服QQ:174666394

有问题请留言,看到后及时答复